<template>
  <div>
      <nav class="navbar navbar-expand-sm bg-dark navbar-dark fixed-top">
  <img class="navbar-brand" src="../img/logo2.jpg" id="a1">
  <ul class="navbar-nav">
    <li class="nav-item">
      <a class="nav-link" href="#">欢迎{{$store.state.Login.name}}登录</a>
    </li>
  </ul>
</nav>
      <div>
          <ul >
              <li>  
                  <div >
                  <a>
                       <img :src="$store.state.tableaa.img">  
                      <div>
                          <h4>{{$store.state.tableaa.name}}</h4>
                          <p >{{$store.state.tableaa.remark}}</p>
                          <p class="item-keywords">
                                <span>适用人群：{{$store.state.tableaa.sex}}</span>
                            
                          </p>
                      </div>
                </a>
                  </div>
            </li>
          </ul>
</div>
<el-form :model="$store.state.Login" >
    <el-form-item label="体检人" >
      <el-text v-text="$store.state.Login.name" readonly="readonly"></el-text>
    </el-form-item>
    <el-form-item label="性别" >
      <el-text v-text="$store.state.Login.sex"></el-text>
    </el-form-item>
    <el-form-item label="手机号" >
      <el-text v-text="$store.state.Login.phoneNumber"></el-text>
    </el-form-item>
    <el-form-item label="身份证号" >
      <el-text v-text="$store.state.Login.idCard"></el-text>
    </el-form-item>
    <el-form-item label="出生日期" >
      <el-text v-text="tt"></el-text>
    </el-form-item>
    <el-form-item label="体检时间">
    <el-col :span="11">
      <el-date-picker type="date" placeholder="选择日期" v-model="date1" style="width: 100%;"></el-date-picker>
    </el-col>
    <el-col class="line" :span="2">-</el-col>
    <el-col :span="11">
      <el-time-picker placeholder="选择时间" v-model="date2" style="width: 100%;"></el-time-picker>
    </el-col>
  </el-form-item>
      <el-button type="primary" @click="tjyy">提交预约</el-button>
      </el-form>
  </div>
</template>

<script>
import axios from 'axios'
import moment from 'moment'
export default {
data() { //moment(this.$store.state.Login.birthday).format("YYYY-MM-DD")
    return {
        date1:'',
        date2:'',
        yyshow:{},
        tt:moment(this.$store.state.Login.birthday).format("YYYY-MM-DD")
    }
},
methods:{
    tjyy(){
        var time=moment(this.date1).format("YYYY-MM-DD");
        if(time<=this.aa()){
            alert("预约时间不能小于或等于当前时间")
        }else{
        axios.post("http://localhost:8085/yyshow",{memberId:this.$store.state.Login.id}).then((response) => {
            this.yyshow=response.data
            console.log(this.yyshow)
            if(this.yyshow==1){
            alert("您已预约，请勿重复预约")
        }else{
            axios.post("http://localhost:8085/tjyy",{memberId:this.$store.state.Login.id,orderDate:time,setmealId:this.$store.state.tableaa.sid}).then((response) => {
          if(response.data){
            alert("预约成功")
            this.$router.push('/home')  
          }
    })
        }
        })
        
        }
        
    },
    aa(){
        var dt=new Date()
        var n=dt.getFullYear();
        var y=(dt.getMonth()+1).toString().padStart(2,"0");
        var r=(dt.getDate()).toString().padStart(2,"0");
        dt.getHours();
        dt.getMinutes();
        dt.getSeconds();
        return n+"-"+y+"-"+r
    },
    
}
}
</script>

<style>
#a1{
  width: 35px;
  height: 40px;
}

</style>